package com.qxzn.module.home.adapter;

import android.app.Activity;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.qxzn.module.home.R;
import com.qxzn.module.home.R2;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class HomeRecommendAdapter extends RecyclerView.Adapter<HomeRecommendAdapter.ViewHolder> {

    private Activity activity;
    private List<Integer> dataList;

    public HomeRecommendAdapter(Activity activity, List dataList) {
        this.activity = activity;
        this.dataList = dataList;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(activity).inflate(R.layout.item_home_recommend, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.ivBg.setImageResource(dataList.get(position));
    }

    @Override
    public int getItemCount() {
        return dataList == null ? 0 : dataList.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R2.id.iv_bg)
        ImageView ivBg;
        @BindView(R2.id.tv_title)
        TextView tvTitle;
        @BindView(R2.id.tv_line_one)
        TextView tvLineOne;
        @BindView(R2.id.tv_line_two)
        TextView tvLineTwo;
        @BindView(R2.id.tv_detail)
        TextView tvDetail;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
